﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Ionic.Zip;

namespace UnzipWizard
{
    public class UnzipHelper
    {
        public virtual void unzipTo(string fromPath, string toPath)
        {

            if (!System.IO.File.Exists(fromPath))
            {
                Console.WriteLine("That zip file does not exist!\n");
                return;
            }
            try
            {
                var options = new ReadOptions { StatusMessageWriter = System.Console.Out };
                using (ZipFile zip = ZipFile.Read(fromPath, options))
                {
                    zip.ExtractAll(toPath);
                    Console.WriteLine("That zip file has extract to " + toPath);
                }
            }
            catch (Ionic.Zip.ZipException)
            {
                Console.WriteLine("That files being extract is already exist!");
            }
            catch (System.Exception ex1)
            {
                System.Console.Error.WriteLine("exception: " + ex1);
            }

        }
    }
}
